package com.study.base.mutilthread.thread;

/**
 * Created by tan on 2017/9/5.
 */
public class ObjectTest {
    public static void main(String[] args) throws InterruptedException {

        Integer a = 10;
        Thread thread = new Thread(() -> {

            //为什么这样设计??
            //调用object.wait()方法前，当前线程要持有object对象锁。否者运行时会抛出IllegalMonitorStateException异常
            //a.wait();
            //object.wait()调用时，会释放object对象锁。
            System.out.println("kkkk");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        thread.start();
     //   thread.join();

        String str = "a".intern();
        synchronized (thread) {
            thread.wait();
        }
        System.out.println("hhh");
    }
}
